package com.xy;

import com.xy.command.Command;
import com.xy.curtain.CurtainOffCommand;
import com.xy.curtain.CurtainOnCommand;
import com.xy.curtain.CurtainReceiver;
import com.xy.light.LightOffCommand;
import com.xy.light.LightOnCommand;
import com.xy.light.LightReceiver;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/16 20:29
 * @description
 */
public class Client {
    public static void main(String[] args) {
        // 接收者
        LightReceiver lightReceiver = new LightReceiver();
        CurtainReceiver curtainReceiver = new CurtainReceiver();

        // 命令
        Command lightOnCommand = new LightOnCommand(lightReceiver);
        Command lightOffCommand = new LightOffCommand(lightReceiver);
        Command curtainOnCommand = new CurtainOnCommand(curtainReceiver);
        Command curtainOffCommand = new CurtainOffCommand(curtainReceiver);
        // 执行者
        RemoteController remoteController = new RemoteController();
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);
        remoteController.setCommand(1,curtainOnCommand,curtainOffCommand);
        System.out.print("开灯按钮\t");
        remoteController.onButtonPushed(0);
        System.out.print("撤销按钮\t");
        remoteController.undo();
        System.out.print("撤销按钮\t");
        remoteController.undo();
        System.out.print("关灯按钮\t");
        remoteController.offButtonPushed(0);
        System.out.println("------------------");
        System.out.print("开窗帘按钮\t");
        remoteController.onButtonPushed(1);
        System.out.print("撤销按钮 \t");
        remoteController.undo();
        System.out.print("撤销按钮 \t");
        remoteController.undo();
        System.out.print("关窗帘按钮\t");
        remoteController.offButtonPushed(1);
    }
}
